<#escape x as (x)!"">
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="${basePackage}.${platPackage}.${modulePackage}.dao.${className}Dao">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="${basePackage}.entity.${modulePackage}.${className}Entity" id="${classname}Map">
	<#if columns??>
		<#list columns as column>
		<result property="${column.attrname}" column="${column.columnName}"/>
		</#list>
	</#if>
    
    </resultMap>
	
	<select id="queryList" resultType="${basePackage}.entity.${modulePackage}.${className}Entity">
		select *
		from 
		<foreach item="item" collection="list_from" open="" separator="," close="">
			${r'${item}'}
		</foreach>
		<where>
			<if test="c">
				and a.servicenumber = c.sevicenumber ( + )
			</if>
			<if test="f">
				and c.areacode = f.codeid
			</if>
			<if test="provinceId != null and provinceId > 0">
				and f.province_id = ${r'#{provinceId}'}
			</if>
			<if test="timeChecked">
				and  a.committime  between to_date( ${r'#{startTime}'}, 'yyyy-mm-dd hh24:mi:ss' ) and to_date( ${r'#{endTime}'}, 'yyyy-mm-dd hh24:mi:ss' )
			</if>
			<foreach item="lopt" collection="list_lopts" open="" separator="" close="">
			    <choose>
			        <when test="lopt.opt==1">
			            and (
			        </when>
			        <otherwise>
			            or ( 
			        </otherwise>
			    </choose>
				<foreach item="cri" index="index" collection="lopt.criList" open="" separator="" close="">
				       <if test="index!=0">
					    <choose>
					        <when test="cri.opt=='and'">
					            and 
					        </when>
					        <otherwise>
					            or 
					        </otherwise>
					    </choose>
					    </if>
						<if test="cri.operator==1">
							${r'${cri.column} = #{cri.value}'}
						</if>
						<if test="cri.operator==2">
							${r'${cri.column}   &lt;&gt; #{cri.value}'}
						</if>
						<if test="cri.operator==3">
							${r'${cri.column} &lt; #{cri.value}'}
						</if>
						<if test="cri.operator==4">
							${r'${cri.column} &gt; #{cri.value}'}
						</if>
						<if test="cri.operator==5">
							${r'${cri.column} &gt;= #{cri.value}'}
						</if>
						<if test="cri.operator==6">
							${r'${cri.column} &lt;= #{cri.value}'}
						</if>
						<if test="cri.operator==7">
							${r'${cri.column}'} like '%${r'${cri.value}'} %'
						</if>
						<if test="cri.operator==8">
							${r'${cri.column} is null'}
						</if>
			     	
			    </foreach>
			    )
			</foreach>		
		</where>  
	</select>


	<select id="queryPageList" resultType="${basePackage}.entity.${modulePackage}.${className}Entity">
		select * from ${tableName}
		<where>
			<if test="createUserId != null">
				and create_user_id = ${r'#{createUserId}'}
			</if>
			<if test="searchName != null and searchName.trim() != ''">
				and demo_name like CONCAT('%',CONCAT(${r'#{searchName}'},'%'))  
			</if>
		</where>  
        <choose>
            <when test="sidx != null and sidx.trim() != ''">
                order by ${r'${sidx} ${order}'}
            </when>
			<otherwise>
                order by ${pk.columnName} desc
			</otherwise>
        </choose>
	</select>
</mapper>
</#escape>